package com.kelaite.procurement.utils;

import javax.servlet.http.HttpServletRequest;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class ApplicationContextUtil {
	
	private static ApplicationContext appCtx = null;
	
	public static ApplicationContext getApplicationCtx(HttpServletRequest request){
		if(appCtx == null){
			appCtx = WebApplicationContextUtils.getRequiredWebApplicationContext(request.getServletContext());
		}
		return appCtx;
	}
	
	public static Object getBean(HttpServletRequest request, String beanName){
		return getApplicationCtx(request).getBean(beanName);
	}
}
